/**   
 * @文件名称: RegisterAction.java
 * @类路径: com.lxj.cms.reception.action
 * @描述: TODO
 * @公司：昆明天度网络信息科技有限公司
 * @作者：李兴建
 * @时间：2013-8-12 下午03:10:57
 * @版本：V1.0   
 */

package com.lxj.cms.reception.action;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.lxj.cms.manage.entity.TgMemberEntity;
import com.lxj.core.action.BaseAction;
import com.opensymphony.xwork2.validator.annotations.EmailValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.Validation;
import com.opensymphony.xwork2.validator.annotations.Validations;
import com.opensymphony.xwork2.validator.annotations.ValidatorType;

/**
 * @类功能说明：
 * @类修改者：
 * @修改日期：
 * @修改说明：
 * @公司：昆明天度网络信息科技有限公司
 * @作者：李兴建
 * @创建时间：2013-8-12 下午03:10:57
 * @版本：V1.0
 */
@SuppressWarnings("serial")
@Namespace(value = "/")
@Results( { @Result(name = "login", type = "redirect", location = "/login.action"), @Result(name = "register", location = "/register.jsp") })
public class RegisterAction extends BaseAction {

	private TgMemberEntity member;

	private String confirmPassword;
	private String captcha;

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		member = new TgMemberEntity();
		return "register";
	}
	@Validations(requiredStrings={    
			 @RequiredStringValidator( fieldName = "confirmPassword", key = "i18n.key",message = " You must enter a value for userName.")})  
	public String register() {
        /**
		boolean tag = true;

		if (!CommonUtils.validataEmail(member.getEmail())) {
			this.addFieldError("emailError", "邮箱格式不正确");
			tag = false;
		}
		if (StringUtils.isEmpty(member.getLoginName()) || member.getLoginName().length() < 4 || member.getLoginName().length() > 16) {
			this.addFieldError("loginNameError", "用户名格式不正确");
			tag = false;
		}
		if (StringUtils.isEmpty(member.getPassword()) || member.getLoginName().length() < 4) {
			this.addFieldError("passwordError", "密码格式不正确");
			tag = false;
		}
		if (StringUtils.isEmpty(confirmPassword) || !confirmPassword.equals(member.getPassword())) {
			this.addFieldError("confirmPasswordError", "两次密码输入不一至");
			tag = false;
		}
		if (null!=ActionContext.getContext().getSession().get("securityCode")&&!(ActionContext.getContext().getSession().get("securityCode")).equals(this.getCaptcha())) {
			this.addFieldError("captchaError", "验证码不正确");
			tag = false;
		}

		if (!tag) {
			return "register";
		} else {
			this.getBaseService().save(member);
			return "login";
		}*/
		this.getBaseService().save(member);
		return "login";

	}

	public TgMemberEntity getMember() {
		return member;
	}

	public void setMember(TgMemberEntity member) {
		this.member = member;
	}

	public String getConfirmPassword() {
		return confirmPassword;
	}
	@RequiredStringValidator(message = "请输入用户名!")
	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public String getCaptcha() {
		return captcha;
	}

	public void setCaptcha(String captcha) {
		this.captcha = captcha;
	}

}
